export default {
  addCart(state, payload) {
    // payload新添加的商品

    // 1.查找之前数组中是否有该商品
    let oldProduct = state.cartList.find(item => item.iid === payload.iid);

    // 2.判断oldProduct是否有值
    if (oldProduct) {
      oldProduct.count += 1;
    } else {
      payload.count = 1;
      state.cartList.push(payload);
    }
  }
}